package com.hg.admin.db.dao;

import java.util.ArrayList;
import java.util.List;

import org.jdiy.core.Args;
import org.jdiy.core.Ls;
import org.jdiy.core.Rs;

import com.hg.admin.db.dto.UserGroupDTO;
import com.hg.util.db.IDao;

public class UserGroupDAO extends IDao
{
	String table = db_prefix+"user_group";
	
	public UserGroupDTO encapsulation(Rs rs){
		UserGroupDTO dto = new UserGroupDTO();
		
		dto.setId(rs.getInt("id"));
		dto.setName(rs.getString("name"));
		dto.setScore(rs.getDouble("score"));
		dto.setDiscount(rs.getDouble("discount"));
		
		return dto;
	}
	
	/**
	 * 获取所有会员组
	 * @return
	 */
	public List<UserGroupDTO> getAll(){
		Args args = new Args(table);
		args.setFilter("1=1");
		Ls ls = dao.ls(args);
		List<UserGroupDTO> list = new ArrayList<UserGroupDTO>();
		for(Rs rs:ls.getItems()){
			list.add(this.encapsulation(rs));
		}
		return list;
	}
}
